package ytdp.careagle.com.ytdp.mvp.presenter;

import android.content.Context;

import ytdp.careagle.com.ytdp.activity.AllCarTypeActivity;
import ytdp.careagle.com.ytdp.app.G;
import ytdp.careagle.com.ytdp.entity.SellCarProgramEntity;
import ytdp.careagle.com.ytdp.mvp.mode.CarEvaluateModel;
import ytdp.careagle.com.ytdp.mvp.view.IAllCarTypeView;
import ytdp.careagle.com.ytdp.net.MyObserver;
import ytdp.careagle.com.ytdp.net.Results;

/**
 * Created by admin on 2017/10/13.
 */

public class AllCarTypePresenter {
    private IAllCarTypeView view;
    private CarEvaluateModel model;
    public AllCarTypePresenter(IAllCarTypeView view) {
        this.view = view;
        model=new CarEvaluateModel();
    }

    public void findVehicleByVehicleSeriesAndOnline(Context context, String id) {
        model.findVehicleByVehicleSeriesAndOnline(context, G.getHeader(context), id, new MyObserver<Results<SellCarProgramEntity>>() {
            @Override
            public void onNext(Results<SellCarProgramEntity> result) {
                super.onNext(result);
                if (result.getCode() == G.REQUEST_OK) {
//                    view.showMessage("success");
                    view.setCarData(result.getData());
                } else {
                    view.showMessage(result.getMessage());
                }
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                view.showMessage("服务器错误");
            }
        });
    }
}
